package ${packageName}.mapper;

import ${packageName}.entity.${className};
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
<#if hasDateType>
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.LocalDateTime;
</#if>
<#if hasBigDecimal>
    import java.math.BigDecimal;
</#if>
/**
 * ${tableComment!''} Mapper
 * 
 * @author ${author}
 * @date ${.now?string("yyyy-MM-dd HH:mm:ss")}
 */
@Mapper
public interface ${className}Mapper extends BaseMapper<${className}> {

<#list columns as column>
    <#if !column.primaryKey>
    /**
     * 根据${column.columnComment!''}查询
     */
    @Select("SELECT * FROM ${tableName} WHERE ${column.columnName} = #{${column.javaFieldName}}")
    List<${className}> selectBy${column.javaPropertyName}(@Param("${column.javaFieldName}") ${column.javaType} ${column.javaFieldName});
    
    </#if>
</#list>
    /**
     * 自定义查询示例
     */
    @Select("SELECT * FROM ${tableName} WHERE ${primaryKeyColumn} = #{${primaryKeyField}}")
    ${className} selectByCustomQuery(@Param("${primaryKeyField}") ${primaryKeyType} ${primaryKeyField});
    
    /**
     * 根据条件统计数量
     */
    @Select("SELECT COUNT(*) FROM ${tableName} WHERE ${primaryKeyColumn} = #{${primaryKeyField}}")
    Long countByCondition(@Param("${primaryKeyField}") ${primaryKeyType} ${primaryKeyField});
}
